package com.hospital.vac.mapper;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.hospital.vac.entity.VaccineOrder;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.poi.ss.formula.functions.T;

/**
 * @ClassName VaccineOrderMapper
 * @Description
 * @Author ANLGIN
 * @Data 2023/3/10 13:59
 */
public interface VaccineOrderMapper extends BaseMapper<VaccineOrder> {
    @Select("select * , u.username 'vaccineOrder.username' ,u.address 'vaccineOrder.address' " +
            ",v.name 'vaccineOrder.name' from user u, vaccine v,vaccine_order vo " +
            "where u.id=vo.user_id and v.id=vo.vaccine_id and ${ew.sqlSegment}")
    Page<VaccineOrder> queryPages(Page<Object> objectPage, @Param("ew") LambdaQueryWrapper<VaccineOrder> wrapper);

    @Select("select * , u.username 'vaccineOrder.username' ,u.address 'vaccineOrder.address' " +
            ",v.name 'vaccineOrder.name' from user u, vaccine v,vaccine_order vo " +
            "where u.id=vo.user_id and v.id=vo.vaccine_id and vo.user_id=#{userId} and ${ew.sqlSegment}")
    Page<VaccineOrder> queryPage(Page<T> tPage,@Param("ew")  LambdaQueryWrapper<VaccineOrder> wrapper, @Param("userId") Integer id);
}
